import sys
import asyncio
from loguru import logger


def init_log():
    logger.remove(handler_id=None)
    log_format = "{time:YYYY.MM.DD-HH.mm.ss.SSS} {message}"
    logger.add(sys.stderr, format=log_format)


async def task(word, time):
    logger.debug(f"start {word}")
    await asyncio.sleep(time)
    logger.debug(f"end {word}")


async def main():
    task1 = asyncio.create_task(task("hello", 2))
    task2 = asyncio.create_task(task("world", 3))
    # await task1,task2
    await task1
    await task2


init_log()
asyncio.run(main())
logger.debug("end")

""" RUN
2024.02.04-17.58.48.510 start hello
2024.02.04-17.58.48.510 start world
2024.02.04-17.58.50.512 end hello
2024.02.04-17.58.51.511 end world
2024.02.04-17.58.51.512 end

"""